package edu.lingnan.reactproject.controller;


import edu.lingnan.reactproject.service.UsersService;
import edu.lingnan.reactproject.vo.AddUserParams;
import edu.lingnan.reactproject.vo.Result;
import edu.lingnan.reactproject.vo.UpdateUserParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 陈世杰
 * @since 2022-01-15
 */
@RestController
@RequestMapping("/manage/user")
public class UsersController {

    @Autowired
    private UsersService usersService;

    @PostMapping("/add")
    public Result add(@RequestBody AddUserParams addUser){
        return usersService.add(addUser);
    }

    @PostMapping("/update")
    public Result update(@RequestBody UpdateUserParams addUser){
        return usersService.update(addUser);
    }

    @GetMapping("/list")
    public Result list(){
        return usersService.getUserList();
    }

    @PostMapping("/delete")
    public Result delete(String userId){
        return usersService.deleteUser(userId);
    }
}

